package com.mc.lp.database.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/*
 * @author aphanda
 * @date Feb 26, 2015
 * @time 9:10:53 PM
 */


@Entity
@Table(name="GRADE_YEAR_MAPPER")
public class GradeYearMapperEntity extends MicroCampusBaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ENTITY_ID")
	private MicroCampusEntity entity;
	
	@Column(name = "START_YEAR")
	private int startYear;
	
	@Column(name = "END_YEAR")
	private int endYear;
	
	@Column(name = "SCHOOL_GRADE")
	private int schoolGrade;

	public MicroCampusEntity getEntity() {
		return entity;
	}

	public void setEntity(MicroCampusEntity entity) {
		this.entity = entity;
	}

	public int getStartYear() {
		return startYear;
	}

	public void setStartYear(int startYear) {
		this.startYear = startYear;
	}

	public int getEndYear() {
		return endYear;
	}

	public void setEndYear(int endYear) {
		this.endYear = endYear;
	}

	public int getSchoolGrade() {
		return schoolGrade;
	}

	public void setSchoolGrade(int schoolGrade) {
		this.schoolGrade = schoolGrade;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + endYear;
		result = prime * result + ((entity == null || entity.getId() == null) ? 0 : entity.getId().hashCode());
		result = prime * result + schoolGrade;
		result = prime * result + startYear;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		GradeYearMapperEntity other = (GradeYearMapperEntity) obj;
		if (endYear != other.endYear)
			return false;
		if (entity == null) {
			if (other.entity != null)
				return false;
		} else if (entity.getId()!=other.entity.getId())
			return false;
		if (schoolGrade != other.schoolGrade)
			return false;
		if (startYear != other.startYear)
			return false;
		return true;
	}
}